﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace UBCon.Ribbon.Converters
{
    internal class ActualWidthConverter:IMultiValueConverter
    {
       
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double width = 0;
            if (values != null && values.Count() == 2) 
            {
                Thickness margin = (Thickness)values[0];
                width = (double)values[1];
                width = width - margin.Left - margin.Right;
            }
            return width > 0 ? width : 0.0D;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
